import Vue from 'vue'
import Router from 'vue-router'



Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'



export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/data',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'data',
      component: () => import('@/views/data/index')
    }]
  },

  {
    path: '/user',
    component: Layout,
    children: [
      {
        path: 'index',
        name: '用户管理',
        component: () => import('@/views/user/index'),
        meta: { title: '用户管理', icon: 'user' }
      }
    ]
  },

  {
    path: '/article',
    component: Layout,
    children: [
      {
        path: 'index',
        name: '文章管理',
        component: () => import('@/views/article/index'),
        meta: { title: '文章管理', icon: 'clipboard' }
      },
      {
        path: 'article/:con/:id',
        name: 'skin',
        component: () => import('@/views/article/article'),
        meta: { title: '文章查看', icon: 'user' },
        hidden: true
      }
    ]
  },

  {
    path: '/classify',
    component: Layout,
    redirect: '/classify/list',
    name: 'Example',
    meta: { title: '分类管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '分类列表',
        component: () => import('@/views/classify/list'),
        meta: { title: '分类列表', icon: 'tree' }
      },
      {
        path: 'edit',
        name: '分类管理',
        component: () => import('@/views/classify/add'),
        meta: { title: '分类管理', icon: 'form' }
      }
    ]
  },
  {
    path: '/banner',
    component: Layout,
    redirect: '/banner/list',
    name: 'banner',
    meta: { title: '轮播图管理', icon: 'size' },
    children: [
      {
        path: 'list',
        name: '轮播图列表',
        component: () => import('@/views/banner/list'),
        meta: { title: '轮播图列表', icon: 'list' }
      },
      {
        path: 'add',
        name: '新增',
        component: () => import('@/views/banner/add'),
        meta: { title: '新增', icon: 'edit' }
      },
      {
        path: 'image/:id',
        name: 'image',
        component: () => import('@/views/banner/image'),
        meta: { title: '图片展示', noCache: true },
        hidden: true
      }
    ]
  },
  // {
  //   path: '/sta',
  //   component: Layout,
  //   redirect: '/sta/show',
  //   name: '统计分析',
  //   meta: { title: '统计分析', icon: 'chart' },
  //   children: [
  //     {
  //       path: 'create',
  //       name: '生成数据',
  //       component: () => import('@/views/sta/create'),
  //       meta: { title: '生成数据', icon: 'table' }
  //     },
  //     {
  //       path: 'show',
  //       name: '图表显示',
  //       component: () => import('@/views/sta/show'),
  //       meta: { title: '图表显示', icon: 'eye' }
  //     }
  //   ]
  // },
  {
    path: '/data',
    component: Layout,
    redirect: '/data/index',
    children: [
      {
        path:'index',
        name:'数据分析',
        component:() => import('@/views/data/index'),
        meta: { title: '数据分析', icon: 'chart' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

